Skip to main content

Complete Module Reference Guide - ABAP Aggregate Demand Report

Back to Overview | ← Previous: Period Utilities

Program Structure Overview

This reference guide provides a complete module-by-module breakdown of the YMTIR_R102_AGGR_DEMAND_REP program with exact line numbers, dependencies, and flow relationships.

Module Classification Matrix

TierModule NameLine RangePurposeDependencies
Tier 1: Core Processing
1select_data1326-1610Data selection engineget_data_marc, check_authority
1process_data1664-2108Demand aggregation engineselect_dataappotion_quantity
1build_output_table_new6566-7060Output table builderprocess_data → ALV display
1alv_report3799-3802Report display controllerfill_field_catalog, build_output_table_new
Tier 2: Period Management
2calulate_acct_periods4885-5050Accounting period calculationbuild_acct_columns
2build_acct_columns5051-5254Accounting column buildercalulate_acct_periods
2calulate_stnd_periods5255-5419Calendar period calculationbuild_stnd_columns
2build_stnd_columns5420-5617Calendar column buildercalulate_stnd_periods
2build_col_date_index2109-2207Weekly period builder→ Used by main processing
Tier 3: UI and Interaction
3display_alv1162-1227ALV container modulelcl_event_receiver
3lcl_event_receiver1068-1137Event handling classdisplay_alv
3user_command_01001240-1255User command handler→ Various forms
3user_command_02001228-1239Popup command handlerdisplay_list
3display_list3849-3963Drill-down popup← Event handlers
Tier 4: Utility and Support
4fill_field_catalog3471-3798Field catalog builder→ ALV display
4get_data_marc1616-1663Material master dataselect_data
4appotion_quantity4359-4396Stock apportionmentprocess_data
4download_file3964-4263File export functionality← User commands
4check_authority1256-1284Authorization validation← Selection screen
4initialize_data1285-1325Data initialization← Program start

Complete Processing Flow with Line References

Critical Data Structures and Their Lifecycle

Material Data Flow

Time Period Data Flow

Module Interaction Matrix

From ModuleTo ModuleData PassedLine Reference
select_dataget_data_marcSelection criteria1360-1363, 1480-1483
process_dataappotion_quantityMaterial, plant, vendor, stock1761-1764
build_output_table_newfill_field_catalogColumn requirementsCalled at line 1045
lcl_event_receiverdisplay_listRow data for drill-down1076
All period formsbuild_output_table_newTime bucket definitionsUsed in loops 6857-6891

Key Business Rules Implementation

Rule 1: Vendor vs Material Mode Processing

" Lines 1346-1539 in select_data
IF r_vendor EQ c_x.
" Vendor mode: Filter by specific vendors first
" Then get materials for those vendors
ELSEIF r_mat EQ c_x.
" Material mode: Get materials first
" Vendor filtering happens later
ENDIF.

Rule 2: Report Type Filtering

" Lines 1776-1855 in process_data
IF p_pd = c_x . " Production Demand
" Keep: Production orders, planned orders
" Remove: Purchase orders, stock transfers
ELSEIF p_co = c_x. " Committed Orders
" Keep: Purchase requisitions, purchase orders
" Remove: Production orders
ELSE. " Sales/Libre
" Keep: Sales orders, deliveries
" Remove: Internal production orders
ENDIF.

Rule 3: Safety Stock Handling

" Lines 6631-6634 in build_output_table_new
IF p_sftstk <> 'X' AND lw_matfcast-extra = 'Safety Stock'.
CONTINUE. " Exclude safety stock if not selected
ENDIF.

Rule 4: Follow-up Material Logic

" Lines 1407-1437 in select_data
" If Material A has follow-up Material B:
" - Include both A (with followup=B) and B (with its own followup)
" - Prevent duplicate entries of Material B
" - Handle multi-level follow-up chains (A→B→C)

Performance Critical Sections

SectionLine RangePerformance ImpactOptimization Used
Material Selection1366-1398High - Large tablesFOR ALL ENTRIES pattern
MRP API Calls1735-1748Very High - External APICalled once per material
Output Table Building6869-6891High - Nested loopsBINARY SEARCH, FROM clause
Field Catalog Building3471-3798Medium - Many columnsStatic definitions where possible
Period Calculations4885-5617Low-MediumSAP standard functions

Error Handling Strategies

Data Selection Errors

" Line 1749 in process_data
CHECK sy-subrc = 0. " Skip materials with MRP API errors

Period Calculation Errors

" Lines 4908-4911 in calulate_acct_periods
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Validation Errors

" Lines 1350-1351 in select_data
IF s_lifnr[] IS INITIAL.
MESSAGE i000 WITH 'Vendor is mandatory'(040).
LEAVE LIST-PROCESSING.
ENDIF.

Memory and Resource Management

Internal Table Sizing

" Efficient internal table declarations
DATA: t_matfcast TYPE type_t_matfcast INITIAL SIZE 0,
t_materials TYPE STANDARD TABLE OF ty_materials INITIAL SIZE 0.

Object Lifecycle

" Lines 1162-1227: ALV objects created once and reused
IF w_container IS INITIAL.
CREATE OBJECT w_container.
CREATE OBJECT w_grid.
" Objects persist for program lifetime
ENDIF.

Integration Points Summary

Incoming Interfaces

  • Selection Screen: User parameters and ranges
  • SAP Standard Tables: MARC, EORD, LFA1, T001W, etc.
  • SAP Standard Functions: MRP API, Period functions, Date functions

Outgoing Interfaces

  • ALV Framework: For report display
  • File System: For data export
  • User Interface: Screens and popups

Internal Integration

  • Global Variables: Shared across all forms
  • Internal Tables: Data passed between processing stages
  • Function Modules: Custom utility functions (YMTIR_*)

Module Dependencies Visualization

This comprehensive reference provides line-exact navigation through the entire program structure, enabling both beginners to understand the flow and experienced developers to quickly locate specific functionality.


Back to Overview | ← Previous: Period Utilities